package com.example.mymusicdisplay.utils;

import android.util.Log;

import com.example.mymusicdisplay.data.music.RequestResult;
import com.example.mymusicdisplay.service.SearchService;

import io.reactivex.rxjava3.core.Flowable;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * author: ts
 * created on: 2021/11/10 下午7:21
 * description:
 */
public class SearchUtil {
    private static final String TAG = "SearchUtil";

    private static final Retrofit mRetrofit = new Retrofit.Builder()
        .baseUrl("https://autumnfish.cn/")
        .addConverterFactory(GsonConverterFactory.create()) //添加转换器
        .addCallAdapterFactory(RxJava3CallAdapterFactory.create()) //添加Rxjava3的适配器
        .build();

    private static final SearchService mSearchService = mRetrofit.create(SearchService.class);

    public static Flowable<RequestResult> getSearchResult(String key) {
        Log.d(TAG, "getSearchResult: getSearchResult = " + key);
        return mSearchService.getSearchResult(key);
    }
}
